﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FlashPay.Service.Impl
{
    using AutoMapper;
    using FlashPay.DAO.Interface;
    using FlashPay.Entity.Parameter;
    using FlashPay.Entity.Response.ExtApiCompat;
    using FlashPay.Service.Interface;
    using System.Linq;

    /// <summary>
    /// 授权业层接口现实
    /// </summary>
    public class ExtApiCompatServiceImpl:ExtApiCompatService
    {
        /// <summary>
        /// 授权数据接口
        /// </summary>
        private readonly ExtApiCompatDao _extApiCompatDao;

        /// <summary>
        /// mapper
        /// </summary>
        private readonly IMapper _mapper;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="extApiCompatDao">授权数据接口</param>
        /// <param name="mapper">mapper</param>
        public ExtApiCompatServiceImpl(ExtApiCompatDao extApiCompatDao, IMapper mapper)
        {
            _extApiCompatDao = extApiCompatDao;
            _mapper = mapper;
        }

        /// <summary>
        /// 获取
        /// </summary>
        /// <param name="id">编号</param>
        public ExtApiCompatResponse Get(int id) {

            var response = new ExtApiCompatResponse();

            var extApiCompat = _extApiCompatDao.Get(id);
            if (extApiCompat != null) {
                response = _mapper.Map<ExtApiCompatResponse>(extApiCompat);
            }
            return response;
        }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public void AddOrEdit()
        {

        }

        /// <summary>
        /// 查看
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<ExtApiCompatResponse> GetList(ExtApiCompatQuery query)
        {
            var response = new List<ExtApiCompatResponse>();

            var list = _extApiCompatDao.GetList(query);
            if (list != null && list.Any()) {
                response = _mapper.Map<List<ExtApiCompatResponse>>(list);
            }
            return response;
        }
    }
}
